package hadoop.sort;


import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class SortMapper extends Mapper<LongWritable, Text,SortBean,Text> {
    SortBean bean =new SortBean();
    Text v = new Text();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        //获取数据并切割
        String []line=value.toString().split(" ");
        String word=line[0];
        Long wordnum=Long.parseLong(line[1]);

        //封装对象
        bean.setWordnum(wordnum);
        v.set(word);

        context.write(bean,v);

    }
}
